<script>
	import api from './utils/api';

	export default {
		globalData: {
			api: api,
			thirdSession: null,
			OAUTH_BEARER_TOKEN:null,
			smmUser:null,
			info:null,
			businessInfo:null,
			categoryId:'',
			wxUser:null,
			
			updateManager() {
				const updateManager = uni.getUpdateManager();
				updateManager.onUpdateReady(function() {
					uni.showModal({
						title: '更新提示',
						content: '新版本已经准备好，是否重启应用？',
						success(res) {
							if (res.confirm) {
								updateManager.applyUpdate();
							}
						}
					});
				});
			},
			//初始化，供每个页面调用 
			initPage: function() {
			},
		
	
			doLogin() {
			},

			//获取当前页面带参数的url
			getCurrentPageUrlWithArgs() {
				const pages = getCurrentPages();
				const currentPage = pages[pages.length - 1];
				const url = currentPage.route;
				const options = currentPage.options;
				let urlWithArgs = `/${url}?`;

				for (let key in options) {
					const value = options[key];
					urlWithArgs += `${key}=${value}&`;
				}

				urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1);
				return urlWithArgs;
			}

		},
		onLaunch: function() {
			//检测新版本
			this.globalData.updateManager();
			uni.getSystemInfo({
				success: e => {
					this.globalData.StatusBar = e.statusBarHeight;
					let custom = uni.getMenuButtonBoundingClientRect();
					this.globalData.Custom = custom;
					this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
				}
			});
		},
		methods: {}
	};
</script>
<style>
	@import "./app.css";
	@import "@/public/uview-ui/index.scss";
</style>
